/*
 * Copyright (C) 2010 mAPPn.Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mol.market.common.widget;

import android.app.ActivityGroup;
import android.os.Bundle;
import android.view.Window;

import com.mol.market.Session;
import com.mol.market.common.network.ResponseCacheManager;

/**
 * 普通页面<br>
 * 
 * 一些基本的页面控制都在这里实现，比如SDK统计，Google统计，内存控制
 * 
 * @author andrew
 * @date    2011-4-20
 * @since Version 0.7.0
 *
 */
public class BaseActivity extends ActivityGroup {

    /** 应用Session */
    protected Session mSession;
    
    /* (non-Javadoc)
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        
        super.onCreate(savedInstanceState);
        mSession = Session.get(getApplicationContext());
        
        //当系统本身并不提供actionbar的时候，我们必须取消原本的Title，再使用actionbarsherlock。
        if(android.os.Build.VERSION.SDK_INT <= 11){
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
        
        //must set theme for app ,this will make all resources initialization
//        DisplayMetrics display = getResources().getDisplayMetrics();
//        int style = display.widthPixels / display.density >= 480? R.style.gfan_theme_land:R.style.gfan_theme_port;
//        setTheme(style);
    }
    
    @Override
    protected void onResume() {
        super.onResume();
//        TCAgent.onResume(this);
    }
  
    @Override
    protected void onPause() {
        super.onPause();
//        TCAgent.onPause(this);
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#onLowMemory()
     */
    @Override
    public void onLowMemory() {
        super.onLowMemory();
        ResponseCacheManager.getInstance().clear();
    }
    
//    @Override
//    public boolean onSearchRequested() {
//        Intent intent = new Intent(getApplicationContext(), SearchActivity.class);
//        startActivity(intent);
//        return true;
//    }
}
